package com.lear.rrbus.data;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.lear.rrbus.utils.Utils;

public class BusAddress {

	private String line;
	private String station;
	private boolean isReverse;

	public BusAddress(String station) {
		if (!station.endsWith("站"))
			this.station = station + "站";
		else
			this.station = station;
	}

	public BusAddress(String line, boolean isReverse) {
		this.line = line;
		this.isReverse = isReverse;
	}

	public String getLine() {
		return line;
	}

	public String getStation() {
		return station;
	}

	public boolean isReverse() {
		return isReverse;
	}

	public void setLine(String line) {
		this.line = line;
	}

	public void setReverse(boolean isReverse) {
		this.isReverse = isReverse;
	}

	public void setStation(String station) {
		this.station = station;
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		String result = null;
		if (line != null) {
			sb.append(Utils.BUSRUNURL);
			try {
				sb.append(URLEncoder.encode(line, "UTF-8"));
			} catch (UnsupportedEncodingException e) {
			}
			// sb.append(Utils.DETAIL);
			// sb.append(isDetail ? "1" : "0");
			sb.append(Utils.REVERSE);
			sb.append(isReverse ? "1" : "0");
			result = sb.toString();
		} else if (station != null) {
			result = Utils.STATIONURL + station;
		}

		return result;

	}
}
